home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
UPC12BS1.ZIP
/
UUCICO
/
COMMLIB.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-02
|
12KB
|
344 lines
/*--------------------------------------------------------------------*/
/* c o m m l i b . C */
/* */
/* Generic communications library interface for UUPC/extended. */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* Changes Copyright (c) 1990-1993 by Kendra Electronic */
/* Wonderworks. */
/* */
/* All rights reserved except those explicitly granted by the */
/* UUPC/extended license agreement. */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* RCS Information */
/*--------------------------------------------------------------------*/
/*
* $Id: commlib.c 1.9 1993/10/02 23:13:29 ahd Exp $
*
* Revision history:
* $Log: commlib.c $
* Revision 1.9 1993/10/02 23:13:29 ahd
* Allow suppressing TCPIP support
*
* Revision 1.8 1993/09/27 00:45:20 ahd
* Allow named pipes under OS/2 16 bit
*
* Revision 1.7 1993/09/24 03:43:27 ahd
* Add os/2 named pipes
*
* Revision 1.6 1993/09/20 04:46:34 ahd
* OS/2 2.x support (BC++ 1.0 support)
* TCP/IP support from Dave Watt
* 't' protocol support
*
* Revision 1.5 1993/07/22 23:22:27 ahd
* First pass at changes for Robert Denny's Windows 3.1 support
*
* Revision 1.4 1993/07/13 01:13:32 ahd
* Don't print NULL communications suite name!
*
* Revision 1.3 1993/07/11 14:38:32 ahd
* Display chosen suite
*
* Revision 1.2 1993/05/30 15:25:50 ahd
* Multiple driver support
*
* Revision 1.1 1993/05/30 00:01:47 ahd
* Initial revision
*
*/
/*--------------------------------------------------------------------*/
/* System include files */
/*--------------------------------------------------------------------*/
#include <stdio.h>
#include <string.h>
#include <time.h>
/*--------------------------------------------------------------------*/
/* UUPC/extended includes */
/*--------------------------------------------------------------------*/
#include "lib.h"
#include "hlib.h"
#include "commlib.h"
#include "ulib.h" // Native communications interface
#if !defined(BIT32ENV) && !defined(FAMILYAPI) && !defined(_Windows)
#include "ulibfs.h" // DOS FOSSIL interface
#include "ulib14.h" // DOS ARTISOFT INT14 interface
#endif
/*--------------------------------------------------------------------*/
/* Use the NOTCPIP to suppress the TCP/IP when you don't */
/* have WINSOCK.H */
/*--------------------------------------------------------------------*/
#if defined(WIN32) || defined(_Windows)
#ifndef NOTCPIP
#include "ulibip.h" // Windows sockets on TCP/IP interface
#define TCPIP
#endif
#endif
#if defined(__OS2__) || defined(FAMILYAPI)
#include "ulibnmp.h" // OS/2 named pipes interface
#endif
#define NATIVE "internal"
/*--------------------------------------------------------------------*/
/* Global variables */
/*--------------------------------------------------------------------*/
boolean portActive; /* Port active flag for error handler */
boolean traceEnabled; // Trace active flag
commrefi activeopenlinep, passiveopenlinep, swritep;
commrefu sreadp;
commrefv ssendbrkp, closelinep, SIOSpeedp, flowcontrolp, hangupp;
commrefB GetSpeedp;
commrefb WaitForNetConnectp;
commrefb CDp;
/*--------------------------------------------------------------------*/
/* Local variables */
/*--------------------------------------------------------------------*/
static FILE *traceStream; // Stream used for trace file
static short traceMode; // Flag for last data (input/output)
// written to trace log
static boolean network = FALSE; // Current communications suite is
// network oriented
currentfile();
/*--------------------------------------------------------------------*/
/* c h o o s e C o m m u n i c a t i o n s */
/* */
/* Choose communications suite to use */
/*--------------------------------------------------------------------*/
boolean chooseCommunications( const char *name )
{
static COMMSUITE suite[] =
{
{ NATIVE, // Default for any opsys
nopenline, nopenline, nsread, nswrite,
nssendbrk, ncloseline, nSIOSpeed, nflowcontrol, nhangup,
nGetSpeed,
nCD,
(commrefb) NULL,
FALSE
},
#if !defined(BIT32ENV) && !defined(_Windows) && !defined(FAMILYAPI)
{ "fossil", // MS-DOS FOSSIL driver
fopenline, fopenline, fsread, fswrite,
fssendbrk, fcloseline, fSIOSpeed, fflowcontrol, fhangup,
fGetSpeed,
fCD,
(commrefb) NULL,
FALSE
},
{ "articomm", // MS-DOS ARTISOFT INT14 driver
iopenline, iopenline, isread, iswrite,
issendbrk, icloseline, iSIOSpeed, iflowcontrol, ihangup,
iGetSpeed,
iCD,
(commrefb) NULL,
FALSE
},
#endif
#if defined(TCPIP)
{ "tcp/ip", // Win32 TCP/IP Winsock interface
tactiveopenline, tpassiveopenline, tsread, tswrite,
tssendbrk, tcloseline, tSIOSpeed, tflowcontrol, thangup,
tGetSpeed,
tCD,
tWaitForNetConnect,
TRUE
},
#endif
#if defined(__OS2__) || defined(FAMILYAPI)
{ "namedpipes", // OS/2 named pipes
pactiveopenline, ppassiveopenline, psread, pswrite,
pssendbrk, pcloseline, pSIOSpeed, pflowcontrol, phangup,
pGetSpeed,
pCD,
pWaitForNetConnect,
TRUE
},
#endif
{ NULL } // End of list
};
int subscript = 0;
/*--------------------------------------------------------------------*/
/* Search for name in suite table */
/*--------------------------------------------------------------------*/
while (( name != NULL ) && (suite[subscript].type != NULL ))
{
if ( equali(name,suite[subscript].type))
break; // Success!
else
subscript++;
} /* while */
if ( suite[subscript].type == NULL )
{
printmsg(0,"chooseCommunications: Invalid suite name %s",
name );
return FALSE;
}
/*--------------------------------------------------------------------*/
/* We have a valid suite, define the routines to use and */
/* return to caller */
/*--------------------------------------------------------------------*/
activeopenlinep = suite[subscript].activeopenline;
passiveopenlinep = suite[subscript].passiveopenline;
sreadp = suite[subscript].sread;
swritep = suite[subscript].swrite;
ssendbrkp = suite[subscript].ssendbrk;
closelinep = suite[subscript].closeline;
SIOSpeedp = suite[subscript].SIOSpeed;
flowcontrolp = suite[subscript].flowcontrol;
hangupp = suite[subscript].hangup;
GetSpeedp = suite[subscript].GetSpeed